package com.polytech.dao;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import com.polytech.beans.Brand;
import com.polytech.beans.Car;
import com.polytech.beans.Category;
import com.polytech.beans.Color;
import com.polytech.beans.Model;

public class MemoryCarDao implements CarDao {

	private HashMap<String, Car>cars=new HashMap<>();
	private ModelDao modelDao;
	private CategoryDao categoryDao;
	public MemoryCarDao(ModelDao modelDao,CategoryDao categoryDao) {
		this.modelDao=modelDao;
		this.categoryDao=categoryDao;
		Car car=new Car("c3021231", "new", 200000,  new Color("red",0), "pics/c4.jpg", modelDao.select("C4") , categoryDao.select("economic"),50);
		insert(car);

		Car car1=new Car("c3021232", "new", 100000,  new Color("red",0), "pics/c3.jpg", modelDao.select("C3") , categoryDao.select("economic"),200);
		insert(car1);
		Car car2=new Car("c3021233", "new", 20000,  new Color("red",0), "pics/c3picasso.jpg", modelDao.select("c3picasso") , categoryDao.select("economic"),100);
		insert(car2);
		Car car3=new Car("c3021234", "new", 200000,  new Color("red",0), "pics/buggatti.jpg", modelDao.select("buggati") , categoryDao.select("highClass"),400);
		insert(car3);
		Car car4=new Car("c3021235", "new", 100000,  new Color("red",0), "pics/a1.jpg", modelDao.select("A1") , categoryDao.select("lowCost"),50);
		insert(car4);
		Car car5=new Car("c3021236", "new", 20000,  new Color("red",0), "pics/a2.jpg", modelDao.select("A2") , categoryDao.select("economic"),100);
		insert(car5);
		
		Car car6=new Car("c3021237", "new", 200000,  new Color("red",0), "pics/a4.jpg", modelDao.select("A4") , categoryDao.select("highClass"),300);
		insert(car6);
		
		Car car7=new Car("c3021238", "new", 100000,  new Color("red",0), "pics/serie1.jpg", modelDao.select("Serie1") , categoryDao.select("highClass"),400);
		insert(car7);
		Car car8=new Car("c3021239", "new", 20000,  new Color("red",0), "pics/x6.jpg", modelDao.select("X6") , categoryDao.select("highClass"),350);
		insert(car8);
		

		Car car9=new Car("c3021241", "new", 100000,  new Color("red",0), "pics/giulietta.jpg", modelDao.select("giulietta") , categoryDao.select("economic"),120);
		insert(car9);
		Car car10=new Car("c3021242", "new", 20000,  new Color("red",0), "pics/4c.jpg", modelDao.select("4C") , categoryDao.select("highClass"),350);
		insert(car10);
	}
	@Override
	public void insert(Car car) {
		cars.put(car.getPlaque(),car);
	}
	@Override
	public Car select(String key) {
		return cars.get(key);
	}
	@Override
	public void remove(Car car) {
		if(cars.containsKey(car.getPlaque()))
			cars.remove(car);
	}
	@Override
	public Collection<Car> selectAll() {
		return cars.values();
	}
}
